home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODF-Interest Archive / June 96 / Re Bug in FW_CInterest? < prev    next >
Encoding:
Internet Message Format  |  1996-12-03  |  3.4 KB  |  [TEXT/ttxt]

  1. Subject:     Re: Bug in FW_CInterest?
  2. Sent:        6/26/96 1:01 PM
  3. Received:    6/26/96 1:21 PM
  4. From:        Laurent Delamare, laurentd@apple.com
  5. Reply-To:    ODF Interest, ODF-Interest@CILabs.ORG
  6. To:          OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
  7.  
  8. >The operator == definition of FW_CInterest in FWIntere.cpp, is giving me
  9. >problems. Seems it always returns TRUE. Perhaps the return condition does
  10. >not get fully evaluated due to precedence. Surrounding the return 
  11. >condition with parentheses may solve the problem.
  12. >
  13. >    return (fNotifier == other.fNotifier && fMessage == other.fMessage);
  14. >...
  15. >
  16. >I don't seem to be able to add more than one interest to the list of a
  17. >particular class object I'm writing. Any idea how I can get around the bug
  18. >easily?
  19.  
  20. Did you get a chance to try your solution? (i.e. rebuild the Foundation 
  21. library with your change)
  22.  
  23. I would need a test case to check your problem because I can't reproduce
  24. it here.  For instance, in ODF Form, I added this in 
  25. CFormView::PostCreateViewFromStream()
  26.  
  27.   frame->AddNotifier(listbox, FW_kListBoxDoubleClickMsg);  // -> current 
  28. code
  29.   frame->AddNotifier(listbox, 1);                          // -> my 
  30. addition
  31.  
  32. and I checked with the debugger that the interest was being added 
  33. correctly
  34. to the list of the frame receiver (because it's a different msg)
  35.  
  36.  
  37. >
  38. >I also noticed the following comment in FW_MNotifier::Notify()
  39. >   while (pair)
  40. >   {
  41. >      // Get the next pair before doing any action in case the object is
  42. >destroyed
  43. >      // in the middle (for instance: OK button closing a dialog)
  44. >      // [LSD] Warning: still dangerous in case the notifier has more than
  45. >1 interest
  46. >
  47. >This appears to be true. Have you worked out a solution?
  48. >
  49. >
  50. >Arni
  51. >
  52.  
  53. I did.  I had to fix that bug recently to make something else work.
  54. The fix is to patch your FWNotifr.cpp file with this new destructor
  55. and rebuild the foundation library: 
  56.  
  57. //----------------------------------------------------------------------
  58. // FW_MNotifier::~FW_MNotifier
  59. //-----------------------------------------------------------------------
  60.  
  61. FW_MNotifier::~FW_MNotifier()
  62. {
  63.     // Notify the receivers that this notifier is being deleted
  64.  
  65.     FW_TOrderedCollectionIterator<FW_SPrivInterestReceiver> 
  66. ite(&fInterestList);
  67.     FW_SPrivInterestReceiver* pair = ite.First();
  68.     
  69.     if (pair == 0)
  70.         return;
  71.     
  72.     // First we build the list of all receivers connected to this notifier
  73.     FW_SOMEnvironment    ev;                
  74.     FW_CNotification notifierDeleted(FW_CInterest(this, 
  75. FW_kNotifierDeletedMsg));
  76.     FW_TOrderedCollection<FW_MReceiver>    receiverList;
  77.  
  78.     while (pair) 
  79.     {
  80.         if (!receiverList.Contains(pair->fReceiver))
  81.             receiverList.AddLast(pair->fReceiver);
  82.  
  83.         pair = ite.Next();
  84.     }
  85.  
  86.     // Now we can send them the notification without danger, even if some are
  87.     // deleted as the result
  88.     FW_TOrderedCollectionIterator<FW_MReceiver> ite2(&receiverList);
  89.     for (FW_MReceiver* receiver = ite2.First(); ite2.IsNotComplete(); 
  90. receiver = ite2.Next())
  91.     {
  92.         receiver->HandleNotification(ev, notifierDeleted);
  93.     }
  94.  
  95.     // ----- Delete all left over interest pair
  96.     while ((pair = fInterestList.First()) != NULL)
  97.     {
  98.         // RemoveInterest will call RemoveReceiver
  99.         pair->fReceiver->RemoveInterest(*pair->fInterest);
  100.     }
  101. }
  102.  
  103.  
  104.  
  105. ______________________________________________________________________
  106. Laurent Delamare               laurentd@apple.com
  107. ODF Team                       http://www.devtools.apple.com/odf/
  108. Apple Computer, Inc.           http://www.opendoc.apple.com/
  109.